/**
 * 详情对话框
 */
var ResumeInfoDlg = {
    data: {
        name: "",
        phone: "",
        avatar: "",
        education: "",
        birthday: "",
        salaryLow: "",
        salaryUp: "",
        company: "",
        postId: "",
        status: "",
        createBy: "",
        createTime: "",
        updateBy: "",
        updateTime: "",
        remark: ""
    }
};

layui.use(['form', 'admin', 'ax'], function () {
    var $ = layui.jquery;
    var $ax = layui.ax;
    var form = layui.form;
    var admin = layui.admin;

    //让当前iframe弹层高度适应
    admin.iframeAuto();

    //获取详情信息，填充表单
    var ajax = new $ax(Feng.ctxPath + "/resume/detail?id=" + Feng.getUrlParam("id"));
    var result = ajax.start();
    console.log(result.data);
    form.val('resumeForm', result.data);
    $('#demo1').attr('src',result.data.avatar);//获取图片
    if (result.data.sex==1){
        $('#sex').append('<div>男</div>');
    }else if (result.data.sex==2){
        $('#sex').append('<div>女</div>');
    }

    var jobExpectList=result.data.jobExpectList;
    var workExpList=result.data.workExpList;
    var proExpList=result.data.proExpList;
    var eduExpList=result.data.eduExpList;

    for (var i=0;i<jobExpectList.length;i++){
        var a='<div style="font-weight: bold;font-size: larger">期望岗位：'+jobExpectList[i].postName+'</div>';
        a+='<div>期望薪资：'+jobExpectList[i].expectSalary+'</div>';
        a+='<div>期望行业：'+jobExpectList[i].industryName+'</div>';
        a+='<hr class="layui-border-orange">';
        console.log("a===========",a);
        $('#expect').append(a);
    }

    for (var i=0;i<workExpList.length;i++){
        var a='<div style="font-weight: bold;font-size: larger">公司名称：'+workExpList[i].companyName+'</div>';
        a+='<div>工作时间：'+formatDate(workExpList[i].startDate)+' 至 '+formatDate(workExpList[i].endDate)+'</div>';
        a+='<div>所在部门：'+workExpList[i].department+'</div>';
        a+='<div>担任职位：'+workExpList[i].postName+'</div>';
        a+='<div>技能特点：'+workExpList[i].skill+'</div>';
        a+='<div>工作内容：'+workExpList[i].jobContent+'</div>';
        a+='<hr class="layui-border-orange">';
        console.log("a===========",a);
        $('#work').append(a);
    }

    for (var i=0;i<proExpList.length;i++){
        var a='<div style="font-weight: bold;font-size: larger">项目名称：'+proExpList[i].name+'</div>';
        a+='<div>项目时间：'+formatDate(proExpList[i].startDate)+' 至 '+formatDate(proExpList[i].endDate)+'</div>';
        a+='<div>担任角色：'+proExpList[i].role+'</div>';
        a+='<div>项目描述：'+proExpList[i].descr+'</div>';
        a+='<div>项目业绩：'+proExpList[i].performance+'</div>';
        a+='<div>项目链接：'+proExpList[i].url+'</div>';
        a+='<hr class="layui-border-orange">';
        console.log("a===========",a);
        $('#project').append(a);
    }

    for (var i=0;i<eduExpList.length;i++){
        var a='<div style="font-weight: bold;font-size: larger">学校名称：'+eduExpList[i].school+'</div>';
        a+='<div>就读时间：'+formatDate(eduExpList[i].startTime)+' 至 '+formatDate(eduExpList[i].endTime)+'</div>';
        a+='<div>学科专业：'+eduExpList[i].major+'</div>';
        a+='<div>最高学历：'+eduExpList[i].education+'</div>';
        a+='<hr class="layui-border-orange">';
        console.log("a===========",a);
        $('#edu').append(a);
    }

    function formatDate(date){
        return date.substr(0,10);
    }


    //表单提交事件
    form.on('submit(btnSubmit)', function (data) {
        var ajax = new $ax(Feng.ctxPath + "/resume/editItem", function (data) {
            Feng.success("更新成功！");

            //传给上个页面，刷新table用
            admin.putTempData('formOk', true);

            //关掉对话框
            admin.closeThisDialog();

        }, function (data) {
            Feng.error("更新失败！" + data.responseJSON.message)
        });
        ajax.set(data.field);
        ajax.start();

        return false;
    });

});